package com.ztmao.shortlink.project.mq.producer;

import com.ztmao.shortlink.project.common.constant.RedisCacheConstant;
import com.ztmao.shortlink.project.dto.biz.ShortLinkStatsRecordDTO;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RBlockingDeque;
import org.redisson.api.RDelayedQueue;
import org.redisson.api.RedissonClient;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * 延迟消费短链接统计发送者
 */
@Component
@RequiredArgsConstructor
@Deprecated
public class DelayShortLinkStatsProducer {
    private final RedissonClient redissonClient;
public void send(ShortLinkStatsRecordDTO shortLinkStatsRecordDTO) {
    RBlockingDeque<Object> blockingDeque = redissonClient.getBlockingDeque(RedisCacheConstant.DELAY_QUEUE_STATS_KEY);
    RDelayedQueue<Object> delayedQueue = redissonClient.getDelayedQueue(blockingDeque);
    delayedQueue.offer(shortLinkStatsRecordDTO, 5, TimeUnit.SECONDS);
    }
}
